﻿#ifndef MBASESCENE_H
#define MBASESCENE_H

#include "plug_item.h"
#include "socket_item.h"
#include "line_item.h"
#include "mbase_object.h"
#include <QGraphicsScene>
#include <QKeyEvent>


class MBaseScene : public QGraphicsScene
{
public:
    explicit MBaseScene(QObject *parent = nullptr);
    ~MBaseScene();

    static int gGridSize; /* 单个小矩形的边长 */
    static int gGridSquares; /* 由深色线构成的矩形的边长由几个小矩形构成 */

    static QColor gBackgroundColor;
    static QColor gForegroundColorDark;
    static QColor gForegroundColorLight;


    static bool isbedrawLine;//是否正在画线

    QPointF gpoint;

    void EnableDrawLine(bool flag);

    //提供修改内部函数bdrawLine的函数接口,前面的就是接口
//    void changeLineState(bool changeLineState){bdrawLine = changeLineState;};

    QGraphicsLineItem *line;

protected:
    //键值事件
    void keyPressEvent(QKeyEvent *event)override;
    void keyReleaseEvent(QKeyEvent *event)override;
    //鼠标事件
    void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)override;
    void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)override;
    void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)override;
    virtual void drawBackground(QPainter *painter, const QRectF &rect) override;


private:
    bool bdrawLine;

};

#endif // MBASESCENE_H
